
#include "XmlServer.h"
#include "MsgReceive.h"
#include "Exception.h"
#include "Logger.h"
#include "XmlRpcServerConnection.h"

XmlServer::XmlServer(int aport){
    itsMsgReceive = NULL;
	XmlRpc::setVerbosity(0);
	port = aport;
itsMsgReceive = new MsgReceive(&xmlServ);
	if(!xmlServ.bindAndListen(port))
		throw NetExeption();
	
	xmlServ.enableIntrospection(true);
	
	
}

XmlServer::~XmlServer() {
    cleanUpRelations();
}

MsgReceive* XmlServer::getItsMsgReceive() const {
    return itsMsgReceive;
}


void XmlServer::run()
{
	std::stringstream log;
	log<<"Uruchamiam server na porcie "<<port;
	Logger::getInstance().write(log);
	xmlServ.work(-1.0);
	
}


void XmlServer::setItsMsgReceive(MsgReceive* p_MsgReceive) {
    itsMsgReceive = p_MsgReceive;
}

void XmlServer::cleanUpRelations() {
    if(itsMsgReceive != NULL)
        {
            itsMsgReceive = NULL;
        }
}

